import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/index.js'
import base from './plugins/base.js'
import './plugins/element.js'
import './assets/styles/reset.css'
import './assets/styles/base.styl'
import './assets/styles/yml-main.styl'
import './assets/styles/iconfont/iconfont.css'
import './plugins/dialogDrag.js'
import './plugins/jquery.min.js'
import './plugins/bootstrap.js'
import './plugins/bootstrap-table.js'
import echarts from 'echarts'
import Print from '@/plugins/print.js'; //打印
Vue.use(Print) // 注册
require('echarts/extension/bmap/bmap')
Vue.prototype.$echarts = echarts;
Vue.config.productionTip = false
Vue.use(base);
router.beforeEach((to, from, next) => {
  const role =localStorage.getItem('ms_username');
  if (!role&& to.path!=='/login'){
    next('/login');
  }else if(to.meta.permission){
    role ==='admin'?next():next('/403');
  }else{
    // 简单的判断IE10及以下不进入富文本编辑器，该组件不兼容
    if (navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor') {
      Vue.prototype.$alert('vue-quill-editor组件不兼容IE10及以下浏览器，请使用更高版本的浏览器查看', '浏览器不兼容通知', {
        confirmButtonText: '确定'
      });
    } else {
      next();
    }
  }
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')